import { fromJS } from 'immutable';
import {
  UPDATE_RECOMMENDLIST,
  LOAD_MORE_RECOMMENDLIST,
  TOGGLE_MORE_RECOMMEND_LIST,
} from './constents';

const defaultState = fromJS({
  topicList: [
    {
      id: 1,
      value: '1234',
    },
    {
      id: 2,
      value: '1234',
    },
    {
      id: 3,
      value: '1234',
    },
    {
      id: 4,
      value: '1234',
    },
    {
      id: 5,
      value: '1234',
    },
    {
      id: 6,
      value: '1234',
    },
    {
      id: 7,
      value: '1234',
    },
    {
      id: 8,
      value: '1234',
    },
    {
      id: 9,
      value: '1234',
    },
  ],
  articleList: [
    {
      id: 0,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 2,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 3,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 4,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 5,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 6,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 7,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 8,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 9,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 10,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 11,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 12,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
    {
      id: 13,
      content: 'qwertyuiudfgyuertyuisdfhjiejcnlsdidncll',
    },
  ],
  recommendList: [
  ],
  showScroll: false,
});

export default (state = defaultState, action: { type: any, value: any }) => {
  switch (action.type) {
    case UPDATE_RECOMMENDLIST:
      return state.set('recommendList', action.value);
    case LOAD_MORE_RECOMMENDLIST:
      return state.set('recommendList', state.get('recommendList').concat(action.value));
    case TOGGLE_MORE_RECOMMEND_LIST:
      return state.set('showScroll', action.value);
    default:
      return state;
  }
};
